#ifndef MAPPROCESSOR_H
#define MAPPROCESSOR_H

#include <QtGui/QMainWindow>
#include <QtWebKit/QWebView>
//#include <QtWebKit/QWebFrame>
#include <QDebug>
#include <QtWebKit>

struct LatLon
{
    long lat;
    long lon;
};
const QString mapaddress("Map/GMap.html");
class MapProcessor : public QObject
{
    Q_OBJECT
public:
    MapProcessor(QWidget * parent,QWidget * pWindow = NULL);

    bool LoadMap(QString address = mapaddress);

    //
    void ClientRequestOrderStart();
    void ClientRequestOrderResetMap();
    void ClientRequestOrderEnd();
    void GetStartEndPos(struct LatLon &start, struct LatLon &end);
    //

    void ClientWaitCarStart(long peopleLat,long peopleLon,long carLat,long carLon);
    void ClientWaitCarChangePos(long peopleLat,long peopleLon,long carLat,long carLon);
    void ClientWaitCarEnd();

    //
    void CarMoveOnStart(long startLat,long startLon,long endLat,long endLon);
    void CarMoveOnChangePos(long carLat,long carLon);
    void CarMoveOnEnd();

public Q_SLOTS:
    void populateJavaScriptWindowObject();
    void setStartPosition(long lat,long lon);
    void setEndPosition(long lat,long lon);

signals:
    void finishLoading(bool);


private:
    QWidget * m_pwindow;
    QWidget * m_parent;
    QWebView * m_view;
    QWebPage * m_webpage;
    QWebFrame * m_mainframe;


public:

    union
    {
        struct LatLon startPos;
        struct LatLon peoplePos;
    };

    union
    {
        struct LatLon endPos;
        struct LatLon carPos;
    };


};

#endif // MAPPROCESSOR_H
